export default class EventBus {
  private events: Map<string, Function>;
  constructor() {
    this.events = new Map();
  }
  on(eventName: string, cb: Function) {
    this.events.set(eventName, cb);
  }
  trigger(eventName: string) {
    if (this.events.has(eventName)) {
      return this.events.get(eventName)?.call(this);
    }
  }
  off(eventName: string) {
    this.events.delete(eventName);
  }
  hasEvent(eventName: string) {
    return this.events.has(eventName);
  }
}
